// pages/find/work/index.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    cover:app.config.host + app.config.cover_img_path,
    isLoaded:false,
    loadtips:'暂无数据信息',
    is_scale:'start',//场景值
    formdata:{
        scale:'start',
        search:'',
        date_start:'',
        date_end:'',
        group_index:'',//分类索引信息
        groupbus_index:'',//业态分类索引ID
        to_branch_id:'',//部门ID
    },
    list:[],//数据信息
    statusNum:{
        start:0,//我发起的
        allocated:0,//待分配
        correct:0,//待整改
        pending:0,//待审批
        pended:0,//已审批
    },
    //状态说明：
    //is_scale:
    //is_scale:start:我发起的
    //is_scale:allocated:待分配
    //is_scale:correct:待整改
    //is_scale:pending :待审批
    //is_scale:pended :已审批
    search:{
        search:'',
        date_start:'',
        date_end:'',
        group_index:'',//分类索引信息
        groupbus_index:'',//业态分类索引ID
        to_branch_id:'',//部门ID
    },
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    app.kuoqi.initPage(this);//基础的数据初始化
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.setData({
        formdata:{
            scale:this.data.is_scale,
            search:this.data.search.search?this.data.search.search:'',
            date_start:this.data.search.date_start?this.data.search.date_start:0,
            date_end:this.data.search.date_end?this.data.search.date_end:0,
            group_index:this.data.search.group_index?this.data.search.group_index:0,
            groupbus_index:this.data.search.groupbus_index?this.data.search.groupbus_index:0,
            to_branch_id:this.data.search.to_branch_id?this.data.search.to_branch_id:0,
        },
    });
    this.loadFlows();
    this.lazyNumber();//懒加载数字加载
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  //获取菜单信息
  doWorker:function(e){
    var scale = e.currentTarget.dataset.scale;
    this.setData({
        is_scale:scale,
        formdata:{
            scale:scale,
            search:'',
            date_start:'',
            date_end:'',
            group_index:0,
            groupbus_index:0,
            to_branch_id:0,
        },
    });
    //然后触发模块重新加载数据信息
    this.loadFlows();
  },
  
  loadWithSearch:function(e){
      //查询的时候的内容
      console.log(e.detail.value.search);
      this.setData({
        formdata:{
            scale:this.data.is_scale,
            search:e.detail.value.search,
            date_start:'',
            date_end:'',
            group_index:0,
            groupbus_index:0,
            to_branch_id:0,
          },
      });
      this.loadFlows();
  },

  //加载流程的信息
  loadFlows:function(){
    this.kqPaginate._initPaginate();
    return false;
  },
  //懒加载数字加载
  lazyNumber:function(){
      var ths = this;
      app.kuoqi.ajax({
          url:'/Api/Flows/Count',
          dataType:'json',
          type:'post',
          success:function(rs){
              if(rs.status==1){
                ths.setData({
                    statusNum:rs.data
                });
              }
          },
      });
  },
})